package 第四轮工作.宁波大学;

import com.alibaba.excel.EasyExcel;
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import 第二轮工作.上海工程技术大学.SHGuBean;

import java.io.IOException;
import java.util.ArrayList;

public class NBU {
    public static void main(String[] args) throws IOException {
        int i = 0;
        NBUBean nbuBean = null;
        ArrayList<NBUBean> nbuBeans = new ArrayList<>();
        Connection connect = Jsoup.connect("https://tutors.eol.cn/web/index/indexblists?service_id=36&special_level1=219&type=1&sid=4038&act=sp");
        Document post = connect.post();
        for (Element elementsByClass : post.getElementsByClass("tab-box")) {
//            System.out.println(elementsByClass.text());
            for (Element element : elementsByClass.getElementsByClass("f_left")) {
                for (Element p : element.getElementsByTag("p")) {
                    nbuBean = new NBUBean();
//                    System.out.println(p.text());
                    switch (i) {
                        case 0:
                            nbuBean.setName(p.text().substring(3, p.text().length()));
                            i++;
                            break;
                        case 1:
                            nbuBean.setZc(p.text().substring(3, p.text().length()));
                            i++;
                            break;
                        case 2:
                            nbuBean.setXi(p.text().substring(5, p.text().length()));
                            i++;
                            break;
                        case 3:
                            nbuBean.setQy(p.text().substring(3, p.text().length()));
                            i++;
                            break;
                        case 4:
                            System.out.println(p.text());
                            i = 0;
                            break;
                    }
                    nbuBeans.add(nbuBean);
                }
            }

        }

//        EasyExcel.write("src/NBU.xlsx", NBUBean.class).sheet("user").doWrite(nbuBeans);


    }
}
